import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            in.nextLine();
            for (int i = 0; i < n; i++) {
                int num = in.nextInt();
                in.nextLine();
                if (num % 2 == 0) {
                    System.out.println(num);
                } else {
                    StringBuilder sb = new StringBuilder();
                    boolean flg = false;
                    int c = 0;
                    while (num > 0) {
                        if (num % 10 % 2 == 0 && !flg) {
                            c  =  num % 10;
                            flg = true;
                        } else {
                            sb.append(num % 10);
                        }
                        num /= 10;
                    }
                    if (flg) {
                        sb.append(c);
                        System.out.println(Integer.parseInt(sb.toString()));
                    } else {
                        System.out.println(-1);
                    }
                }
            }
        }
    }
}
